package com.example.xd.permissionlibrary.weigth

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.TextureView
import android.view.View
import android.widget.TextView
import com.example.xd.permissionlibrary.R
import kotlinx.android.synthetic.main.dcp_dialog_layout.*

/**
 * @auther XuDan on 2020/8/10.
 */
class Permission_Dialog(context: Context) : Dialog(context, R.style.permission_dialog),
    View.OnClickListener {
    var contentTv: TextView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dcp_dialog_layout)
        contentTv = findViewById(R.id.dialog_content)
        setCanceledOnTouchOutside(false)
        initClick()
    }

    private fun initClick() {
        dcp_dialog_ok_tv.setOnClickListener(this)
        dcp_dialog_cancle_tv.setOnClickListener(this)
    }

    var dialogOKListener: DialogOKListener? = null
    override fun onClick(v: View?) {
        when (v) {
            dcp_dialog_cancle_tv -> dialogOKListener?.dialogCancle()
            dcp_dialog_ok_tv -> dialogOKListener?.dialogOk()

        }
    }

    fun setDialogOkListener(dialogOKListener: DialogOKListener) {
        this.dialogOKListener = dialogOKListener
    }

    fun setContent(content: String) {
        contentTv?.setText(content)
    }

    interface DialogOKListener {
        fun dialogOk()
        fun dialogCancle()
    }

}